// Author: Bjorn Schobben


#ifndef TEXTURE_H
#define TEXTURE_H

#include "Pixel.h"
#include <string>

class Texture
{
public:
	//Constructors
	Texture(int newHeight, int newWidth);
	Texture(const std::string& filename);
	Texture(const Pixel& solid);
	Texture(const Texture& rhs);

	//Destructor
    virtual ~Texture();

	//Get the heigh and width of this texture
	unsigned int GetHeight() const;
	unsigned int GetWidth() const;

	bool IsSolidColor() const;
	
	//Get a pixel from the texture
	const Pixel& GetPixel(unsigned int x, unsigned int y) const;

	//Set the texture to 1 color
	void SetSolidColor(const Pixel& solid);
	const Pixel& GetSolidColor() const;
	void SetPixel(unsigned int x, unsigned int y, const Pixel& color);

	//Operator easily access a certain pixel
	const Pixel& operator()(unsigned int x, unsigned int y) const;

	const Pixel& GetUserColor() const;
	void SetUserColor(const Pixel& color);

	const std::string& GetName() const;
	void SetName(const std::string& name);

	Texture& operator=(const Texture& rhs);

private:
	//Function to allocate the pixeldata array
	void Allocate();

	void Clear();

	//Height and width (in pixels) of this texture
	unsigned int height;
	unsigned int width;

	//The array of pixels that represents the texture
	Pixel* pixeldata;

	Pixel solidColor;
	Pixel userColor;

	std::string name;

	static const unsigned int DEFAULT_SOLIDHEIGHT = 64;
	static const unsigned int DEFAULT_SOLIDWIDTH = 64;
};

#endif // TEXTURE_H
